package com.topone.controller;

import com.topone.service.PictureService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletResponse;

@RestController
@RequestMapping("/download")
public class PictureController {

    @Autowired
    private PictureService pictureService;

    @RequestMapping(value = "/pay/{businessId}",method = RequestMethod.GET)
    public byte[] payPicture(@PathVariable String businessId, HttpServletResponse response) {
        return pictureService.picturePay(businessId,response);
    }

    @RequestMapping(value = "/info/{businessId}",method = RequestMethod.GET,
                   produces = MediaType.APPLICATION_OCTET_STREAM_VALUE)
    public byte[] payInfo(@PathVariable String businessId, HttpServletResponse response) {
        return pictureService.pictureInfo(businessId,response);
    }
}
